<%@page import="java.awt.print.Printable"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>_预包装拣货任务</title>
<script type="text/javascript">
  
   //完成拣货任务
   function completeTask(taskId){
	   $("#btn_complete").attr("disabled", true);
       $.ajax({
			type:'post',
			url:'${ctx}/prepkgPick/ajaxCompletePickTask',
			data:{
				taskId:taskId
			},
			dataType:'json',
			success:function(data) {
			    if(data==true){
			      window.alert("完成拣货！！请按“确定”继续。"); 
		          location.href='${ctx}/prepkgPick/toPrepkgTaskListPage';
			    }else{
			      $("#btn_complete").attr("disabled", false);
			      alert("网络繁忙，请稍后重试...");
			    }
			},
			error:function() {
				$("#btn_complete").attr("disabled", false);
				alert("网络繁忙，请稍后重试...");
			}
	   });
       
   }
   
</script>
</head>

<body>

    <table class="table table-striped table-bordered table-condensed" style="margin-top: 0px;">
		<thead>
			<th style="vertical-align: middle; color: white; " colspan="12" bgcolor="#8EB4CB">任务信息</th>
		</thead>
		<thead><tr>
		        <th>商家</th>
		        <th>仓库</th>
			    <th>任务编号</th>
			    <th>sku数量</th>
			    <th>商品数量</th>
			    <th>任务状态</th>
			    <th>操作</th>
			</tr>
	   </thead>
	   <tr>
	      <td>${task.customerCode}</td>
	      <td>${task.warehouseCode}</td>
	      <td>${task.taskCode}</td>
	      <td>${task.skuNum}</td>
	      <td>${task.goodsNum}</td>
	      <td>
		     <c:if test="${task.status eq 'undo'}"><font color=blue>创建任务</font></c:if>
		     <c:if test="${task.status eq 'token'}"><font color=blue>领取任务</font></c:if>
		     <c:if test="${task.status eq 'doing'}"><font color=blue>拣货中</font></c:if>
		     <c:if test="${task.status eq 'finish'}"><font color=blue>拣货完成</font></c:if>
	     </td>
	     <td>
           <a href=""  role="button" class="btn btn-info" >导出拣货单</a>
           <c:if test="${task.status eq 'token' or task.status eq 'doing'}">
               <input type="button" class="btn btn-primary" id="btn_complete" value="完成拣货" onclick="completeTask('${task.id}');">
           </c:if>
	     </td>
	   </tr>
	</table>

	
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
	    <thead>
			<th style="vertical-align: middle; color: white; " colspan="11" bgcolor="#8EB4CB">拣货明细</th>
		</thead>
		<thead><tr>
			    <th>序号</th>
			    <th>出库单编号</th>
			    <th>仓库</th>
			    <th>SKU编号</th>
			    <th>库位</th>
			    <th>箱号</th>
			    <th>数量</th>
			</tr></thead>
		<tbody>
		<c:forEach items="${itemList}" var="o" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			   <td>${o.taskCode}</td>
			   <td>${o.warehouseCode}</td>
			    <td>${o.sku}</td>
			     <td>${o.stockCode}</td>
			      <td>${o.boxCode}</td>
			       <td>${o.num}</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	
</body>
</html>
